package com.bit.springboot_1;


import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.net.http.HttpResponse;

@Controller //标识要进行扫描,并返回静态页面
@RequestMapping("/Response")
public class Response {

    @RequestMapping("/getHtml")
//    @ResponseBody  这是标识返回数据
    public String getHtml(){

        return "/index.html";
    }

    @RequestMapping("/getStudent")
    @ResponseBody//spring自动把对象封装为json数据传输
    public Student getStudent(){
        Student s=new Student("zhangsan",18,"1234","man");
        return s;
    }

    @RequestMapping("getStatus")
    @ResponseBody
    public String getStatus(HttpServletResponse response){
        response.setStatus(400);
        return "设置状态码成功!";
    }

}
